package com.pioneer.util;



import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;

/*
 * Author: gchen
 * Created: Sunday, January 11, 2004 7:58:08 PM
 * Modified: Sunday, January 11, 2004 7:58:08 PM
 */


public class AppProperties
{
	
	
	// IMMUTABLE APPLICATION FILENAMES
	private static final String DBPROP="db_prop.txt";
	private static final String LDAPPROP = "ldap_prop.txt";
	private static final String PATHPROP="paths_prop.txt";		
	
	
	// directory of configation files
	public static final String CONFIG_PATH="config";
	
	// EXTERNAL PROPERTY FILE CONSTANTS
	public static final String MANIFEST_XSL = "manifest_xsl";
	public static final String JOB_QUOTE_XSL = "job_quote_xsl";
	public static final String USERDIR="userdir";
	public static final String USERFILE="userfile";	
	public static final String WEBBROWSER_COMMAND = "webbrowser_command";	
	public static final String ACROBAT_COMMAND="acrobat_command";
	public static final String EXCEL_COMMAND = "excel_command";
	public static final String USERNAME = "username";
	public static final String PASSWORD = "password";	
	public static final String SKIN = "skin";	
	public static final String EXPORT_FILE_NAME = "export_file_name";	
	public static final String LOGFILE="logfile";
	public static final String ERRORFILE="errorfile";
	public static final String PDF_FILE="pdf_file";
	public static final String JOB_QUOTE_CONTACT_EDITOR_URL="job_quote_contact_editor_url";
	public static final String METALS_CONTACT_EDITOR_URL="metals_contact_editor_url";
	public static final String CHAT_SERVER="chat_server";
	public static final String CHAT_PORT="chat_port";
	public static final String METALS_LDAP_CONTEXT = "metalsLdapContext";
	public static final String JOB_QUOTES_LDAP_CONTEXT = "jobQuoteLdapContext";
	public static final String PEOPLE_CONTEXT = "peopleContext";	
	
	private static Properties props;
	
	private AppProperties() {
	}
	
	public static void init()
	throws IOException{		
		props = new Properties();
		props.load(new FileInputStream(CONFIG_PATH+java.io.File.separator+DBPROP));
		props.load(new FileInputStream(CONFIG_PATH+java.io.File.separator+LDAPPROP));
		props.load(new FileInputStream(CONFIG_PATH+java.io.File.separator+PATHPROP));
		String userDir = props.getProperty(USERDIR);
		props.load(new FileInputStream(userDir+java.io.File.separator+props.getProperty(USERFILE)));		
	}
	
	public static Properties getProperties() {
		return props;
	}
	
	public static String getProperty(String key) {
		return props.getProperty(key);
	}

}
